package vn.vfriends.vbox.redis;

import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.inject.Singleton;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 *
 * @author tuancn
 */
public class JedisPoolFactory {
    
    private final String host = "113.164.1.27";
    
    private JedisPool jedisPool;
    
    @Singleton
    public @Produces JedisPool getJedisPool() {
        jedisPool = new JedisPool(new JedisPoolConfig(), host);
        return jedisPool;
    }
    
    public void destroy(@Disposes JedisPool jedisPool){
        jedisPool.destroy();
    }
}
